import React from "react";
import App from "@src/App";
import Error from "@src/views/error";

export interface RouteConfigDeclaration {
  /**
   * 当前路由路径
   */
  path: string;
  /**
   * 当前路由名称
   */
  name?: string;
  /**
   * 页面标题
   */
  title?: string;
  /**
   * 是否严格匹配路由
   */
  exact?: boolean;
  /**
   * 是否需要路由鉴权
   */
  isProtected?: boolean;
  /**
   * 是否需要路由重定向
   */
  isRedirect?: boolean;
  /**
   * 是否需要动态加载路由
   */
  isDynamic?: boolean;
  /**
   * 动态加载路由时的提示文案
   */
  loadingFallback?: string;
  /**
   * 路由组件
   */
  component: any;
  /**
   * 子路由
   */
  routes?: RouteConfigDeclaration[];
}
export const routesConfig: RouteConfigDeclaration[] = [
  {
    path: "/",
    name: "root-route",
    component: App,
    routes: [
      {
        path: "/home",
        name: "Home",
        title: "首页",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/home")),
      },
      {
        path: "/login",
        name: "Login",
        title: "Login",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/login")),
      },
      {
        path: "/error",
        name: "Error",
        title: "崩溃了",
        isDynamic: true,
        component: Error,
      },
      {
        path: "/redux-example",
        name: "ReduxExample",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/example/reduxExample")),
        routes: [
          {
            path: "/redux-example/class",
            name: "classReduxExample",
            title: "classReduxExample",
            exact: true,
            isDynamic: true,
            component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/example/classReduxExample")),
          },
          {
            path: "/redux-example/function",
            name: "funcReduxExample",
            title: "funcReduxExample",
            exact: true,
            isDynamic: true,
            component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/example/funcReduxExample")),
          },
        ],
      },
      {
        path: "/glassmorphism",
        name: "Glassmorphism",
        title: "Glassmorphism",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/example/glassmorphism")),
      },
      {
        path: "/flybird",
        name: "Flybird",
        title: "Flybird",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/flybird")),
      },
      {
        path: "/greedySnake",
        name: "GreedySnake",
        title: "GreedySnake",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/GreedySnake")),
      },
      {
        path: "/threejs",
        name: "Threejs",
        title: "Threejs",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/threejs")),
      },
      {
        path: "/three-space",
        name: "ThreeSpace",
        title: "ThreeSpace",
        isDynamic: true,
        component: React.lazy(() => import(/* webpackChunkName: "home" */ "@src/views/threeSpace")),
      },
    ],
  },
];
